<style lang="less">
    @import '../../styles/common.less';
    @import '../tables/components/table.less';
</style>
<template>
    <div>
        <Form  :label-width="100" style="height: 38px;">
            <Input v-model="phone"   placeholder="请输入最小持仓量" style="width: 200px;margin-right: 3px;float: left"></Input>
            <Input v-model="name"   placeholder="请输入最大持仓量" style="width: 200px;margin-right: 3px;float: left"></Input>
            <DatePicker v-model="ct" type="datetime" placeholder="请输入开始时间" style="width: 200px"></DatePicker>
            <DatePicker v-model="st" type="datetime" placeholder="请输入截止时间" style="width: 200px"></DatePicker>
            <FormItem label="订单状态" style="width: 300px;display: inline-block" >
                <Select  v-model="star" style="margin-right: 3px;" >
                    <Option value="1">买入 </Option>
                    <Option value="0">卖出</Option>
                </Select>
            </FormItem>
            <div style="float: right">
            <Button type="info" style="float: right;margin-right: 5px" @click="loads">查询</Button>
            </div>
        </Form>
        <Table :loading="loading" refs="table1"  :data="Message" :columns="columnsList"></Table>
        <Page :total="pageNum" :page-size="pageSize"  style="text-align: center;margin-top: 15px;"  @on-change="pageChange"></Page>
    </div>
</template>
<script>
    import $http from '../../utils/axiosWrap'
    import canEditTable from '../tables/components/canEditTable.vue'
    export default {
        data() {
            return {
                columnsList: [
                    {
                        title: '序号',
                        width: 80,
                        align: 'center',
                        render: (h, params) => {
                            return  params.index + (this.initPage- 1) * this.pageSize + 1
                        }
                    },
                    {
                        title: '订单ID',
                        align: 'center',
                        key: 'id',
                        editable: true
                    },
                    {
                        title: '卖家名',
                        align: 'center',
                        key: 'sellerName',
                        editable: true
                    },
                    {
                        title: '买家名',
                        align: 'center',
                        key: 'buyerName',
                        editable: true
                    },
                    {
                        title: 'USDI价格',
                        align: 'center',
                        key: 'usdPrice',
                        editable: true
                    },
                    {
                        title: '交易数量',
                        align: 'center',
                        key: 'number',
                        editable: true
                    },
                    {
                        title: '币种名称',
                        align: 'center',
                        key: 'coinName',
                        editable: true
                    },
                    {
                        title: '买家剩余AITC',
                        align: 'center',
                        key: 'buyAitc',
                        editable: true
                    },
                    {
                        title: '卖家剩余AITC',
                        align: 'center',
                        key: 'sellAitc',
                        editable: true
                    },
                    {
                        title: '创建时间',
                        align: 'center',
                        width: 160,
                        render: (h, params) => {
                            if(params.row.createDate){
                                return params.row.createDate.replace(/\T/g, ' ').substring(0,19)
                            }else{
                                return ''
                            }
                        }
                    }
                ],
                name: 10000000,
                pageNum:0,
                initPage:1,
                pageSize:10,
                ct:0,
                st: '',
                phone:0,
                loading: true,
                Message:[],
                star:'0'
            }
        },
        created: function () {
            this.st = new Date();
            this.loads()
        },
        methods: {
            pageChange(index){
                this.initPage = index
                this.loading = true
                this.load ()
            },
            load (){
                let _this = this
                var date = new Date(_this.ct);
                var month = date.getMonth() + 1
                var day =  date.getDate()
                var hours =   date.getHours()
                var minutes = date.getMinutes()
                var datese = date.getSeconds()
                if(datese /1  < 10){
                    datese = '0' +  datese
                }
                if(month /1  < 10){
                    month = '0' +  month
                }
                if(day /1  < 10){
                    day = '0' +  day
                }
                if(hours /1  < 10){
                    hours = '0' +  hours
                }
                if(minutes /1  < 10){
                    minutes = '0' +  minutes
                }
                _this.ct = date.getFullYear() + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + datese
                var dates = new Date(_this.st);
                var months = dates.getMonth() + 1
                var days =  dates.getDate()
                var hourss =   dates.getHours()
                var minutess = dates.getMinutes()
                var datases = dates.getSeconds()
                if(datases /1  < 10){
                    datases = '0' +  datases
                }
                if(months /1  < 10){
                    months = '0' +  months
                }
                if(days /1  < 10){
                    days = '0' +  days
                }
                if(hourss /1  < 10){
                    hourss = '0' +  hourss
                }
                if(minutess /1  < 10){
                    minutess = '0' +  minutess
                }
                _this.st = dates.getFullYear() + '-' + months + '-' + days + ' ' + hourss + ':' + minutess + ':' + datases;
                let params = new URLSearchParams()
                params.append('maxAitc',_this.name)
                params.append('minAitc',_this.phone)
                params.append('business',_this.star)
                params.append('startDate',_this.ct)
                params.append('endDate',_this.st)
                params.append('page',_this.initPage)
                params.append('pageSize',_this.pageSize)
                $http.post('/backgroundTransfer/haveAitc',params).then(function (res) {
                    _this.Message = res.result.list
                    _this.loading = false
                    _this.pageNum = res.result.total
                })
            },
            loads(){
                let _this = this
                var date = new Date(_this.ct);
                console.log(date)
                var month = date.getMonth() + 1
                var day =  date.getDate()
                var hours =   date.getHours()
                var minutes = date.getMinutes()
                var datese = date.getSeconds()
                if(datese /1  < 10){
                    datese = '0' +  datese
                }
                if(month /1  < 10){
                    month = '0' +  month
                }
                if(day /1  < 10){
                    day = '0' +  day
                }
                if(hours /1  < 10){
                    hours = '0' +  hours
                }
                if(minutes /1  < 10){
                    minutes = '0' +  minutes
                }
                _this.ct = date.getFullYear() + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + datese
                var dates = new Date(_this.st);
                var months = dates.getMonth() + 1
                var days =  dates.getDate()
                var hourss =   dates.getHours()
                var minutess = dates.getMinutes()
                var datases = dates.getSeconds()
                if(datases /1  < 10){
                    datases = '0' +  datases
                }
                if(months /1  < 10){
                    months = '0' +  months
                }
                if(days /1  < 10){
                    days = '0' +  days
                }
                if(hourss /1  < 10){
                    hourss = '0' +  hourss
                }
                if(minutess /1  < 10){
                    minutess = '0' +  minutess
                }
                _this.st = dates.getFullYear() + '-' + months + '-' + days + ' ' + hourss + ':' + minutess + ':' + datases;
                let params = new URLSearchParams()
                params.append('maxAitc',_this.name)
                params.append('minAitc',_this.phone)
                params.append('business',_this.star)
                params.append('startDate',_this.ct)
                params.append('endDate',_this.st)
                params.append('pageSize',_this.pageSize)
                params.append('page','1')
                $http.post('/backgroundTransfer/haveAitc',params).then(function (res) {
                    console.log(res)
                    if(res.suc){
                        _this.Message = res.result.list
                        _this.loading = false
                        _this.pageNum = res.result.total
                    }else{
                        if(res.msg == "请先登录"){
                            _this.$Message.error('请重新登录！');
                        }else{
                            _this.$Message.error(res.msg);
                        }
                    }
                })
            }
        }
    }
</script>
<style>
    .ivu-form-item {
        margin-bottom: 5px;
    }
</style>

